#version 430 core

#define BLOCK_COUNT 200

layout (std140) uniform UniformParams {
	mat4 projection;
	mat4 view;
	mat4 viewProjMat;
	mat4 biasMat;
	mat4 shadowProjection; //shadow ortho projection
	mat4 worldToLightMat; //light space transform
	vec4 camPosition;
	vec4 lightDir;
} uParams;

uniform ShaderParams
{
	mat4 model[BLOCK_COUNT];
}params;

 
layout(location = 0) in vec3 position;
layout(location = 1) in vec3 normal;
layout(location = 2) in vec2 texCoord;

layout(location = 3) in unsigned int id;

out float shadowCoord;

void main(){
	//get position in clip space and give it to fragment shader
	mat4 model = params.model[id];
    vec4 worldPos = model * vec4(position,1);
    gl_Position = uParams.shadowProjection * uParams.worldToLightMat * worldPos;

	shadowCoord = gl_Position.z;
}